package com.tbit.uqbike.client.service.impl;

import com.tbit.uqbike.client.dao.core.MemberLogDao;
import com.tbit.uqbike.client.pojo.MemberLog;
import com.tbit.uqbike.client.service.MemberLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author chenmengran
 * @Description: 会员开通记录
 * @date 2019\7\18 001811:51
 */
@Service
public class MemberLogServiceImpl implements MemberLogService {
    @Autowired
    private MemberLogDao memberLogDao;

    @Override
    public List<MemberLog> findByUserId(Integer userId, Integer accountId) {
        Map<String, Object> map = new HashMap<>();
        map.put("userId", userId);
        map.put("accountId", accountId);
        return memberLogDao.findByUserId(map);
    }

    @Override
    public void insert(MemberLog memberLog) {
        memberLogDao.insert(memberLog);
    }

    @Override
    public MemberLog findByOrderNo(String orderNO) {
        return memberLogDao.findByOrderNo(orderNO);
    }

    @Override
    public void update(MemberLog memberLog) {
        memberLogDao.update(memberLog);
    }

    @Override
    public List<MemberLog> getUserRide(Integer accountId, String startTime, String endTime) {
        Map<String, Object> map = new HashMap<>();
        map.put("startTime", startTime);
        map.put("endTime", endTime);
        map.put("accountId", accountId);
        return memberLogDao.getUserRide(map);
    }

    @Override
    public Boolean hasValidCard(Integer userId) {
        return memberLogDao.hasValidCard(userId) > 0;
    }

    @Override
    public MemberLog getMemberLogByUserId(Integer userId, Integer accountId) {
        return memberLogDao.getMemberLogByUserId(userId, accountId);
    }
}
